<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter">
        </table>
        <script type="text/html" id="currentTableBar">
            {{# if(d.checkAccept == 1){ }}
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-applyPutOnRecords"
               lay-event="accept">同意</a>
            {{# }if(d.checkAccept == 2){ }}
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-applyPutOnRecords"
               lay-event="">已同意</a>
            {{# }}}

            <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="load">下载</a>
        </script>

    </div>
</div>
<script src="../js/lay-module/http/http.js"></script>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>

    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;


        table.render({
            elem: '#currentTableId',
            url: $api + 'assit/expert/accept',
            toolbar: '#toolbarDemo',
            headers: {
                Authorization: layui.data('table')['Authorization']
            },
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                // {type: "checkbox", width: 50},
                {type: "numbers", width: 50},
                {field: "id", title: "主键", hide: true},
                {field: "project_id", title: "项目id", hide: true},
                {field: "name", title: "项目名称", width: 100},
                {field: "startTime", title: "启动时间", width: 100},
                {field: "endTime", title: "结束时间", width: 100},
                {field: "introduce", title: "简要介绍", width: 100},
                {field: "expectEffect", title: "预期效果", width: 100},
                {field: "projectType", title: "项目类型", width: 100, templet: function (res){
                    return getProjectType(res.projectType)
                    }
                },
                {field: "applicationTime", title: "申报时间", width: 100},
                {field: "firm", title: "所属单位", width: 100},
                {field: "department", title: "所属部门", width: 100},
                {field: "principal", title: "项目负责人", width: 100},
                {field: "qrCode", title: "二维码", hide: true},
                {field: "barCode", title: "条形码", hide: true},
                {field: "evolve", title: "项目进展", width: 100},
                {field: "putOnRecords", title: "是否备案", width: 100, templet: function (res) {
                        return getPutOnRecords(res.putOnRecords)
                    }
                },
                {field: "checkAccept", title: "是否验收", width: 100, templet: function (res) {
                        return getCheckAccept(res.checkAccept)
                    }
                },
                {field: "state", title: "项目状态", width: 100},
                {field: "achievement", title: "项目成果", width: 100},
                {title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
            ]],
            limits: [10, 5, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'line',
            done:function (res) {
                identifyCode(res)
            }
        });


        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            console.log(JSON.stringify(data))
            if (obj.event === 'accept') {

                $.ajax({
                    type: 'GET',
                    url: $api + '/assit/expert/update/expertProject?id=' + data.id,
                    contentType: "application/json;charset=utf-8",
                    async: false,
                    headers: {
                        'Authorization': layui.data('table')['Authorization']
                    },
                    success: function (res) {
                        alert("操作成功")
                        window.location.reload($api + 'projectLibrary/project/select/project/by/type')
                    }
                });

                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if(obj.event == 'load'){
                $.ajax({
                    type: 'GET',
                    url: $api + 'projectLibrary/project/create/pdf?id=' + data.id,
                    contentType: "application/json;charset=utf-8",
                    async: false,
                    headers: {
                        'Authorization': layui.data('table')['Authorization']
                    },
                    success: function (res) {
                        identifyCode(res)
                        window.location.href = res.data
                    }
                });
            }
        });

    });
</script>

</body>
</html>